package crp.services.api.graphql.models;

import crp.core.workflow.domain.models.WorkflowDefinitionNode;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import org.eclipse.microprofile.graphql.Id;
import org.eclipse.microprofile.graphql.Type;

import javax.validation.constraints.NotNull;

@Type("WorkflowNode")
@Builder
@Getter
@AllArgsConstructor
public class WorkflowNodePayload {
    @Id
    @NotNull
    private final String id;
    @NotNull
    private final String name;
    @NotNull
    private final boolean current;
    @NotNull
    private final boolean been;

    public static WorkflowNodePayload of(WorkflowDefinitionNode node, boolean current, boolean been) {
        return WorkflowNodePayload.builder()
                .id(node.getId())
                .name(node.getName())
                .current(current)
                .been(been)
                .build();
    }
}
